package com.hl.mapper;

import com.hl.pojo.PsychologicalKnowledge;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface PsychologicalKnowledgeMapper {
    // 添加心理知识
    @Insert("insert into psychological_knowledge (title, intro, list_image, detail_content) values (#{title}, #{intro}, #{listImage}, #{detailContent})")
    public Integer add(PsychologicalKnowledge psychologicalKnowledge);

    // 查询所有心理知识（未删除）
    @Select("select * from psychological_knowledge where del = 0")
    public List<PsychologicalKnowledge> findAll();

    // 根据id删除心理知识（软删除）
    @Update("update psychological_knowledge set del = 1 where id = #{id}")
    public Integer del(Integer id);

    // 根据id查询心理知识
    @Select("select * from psychological_knowledge where id = #{id}")
    public PsychologicalKnowledge findById(Integer id);

    // 更新心理知识
    @Update("update psychological_knowledge set title=#{title}, intro=#{intro}, list_image=#{listImage}, detail_content=#{detailContent} where id=#{id}")
    public Integer update(PsychologicalKnowledge psychologicalKnowledge);
}